package server;

/**
 * @Author: Tao Zheng
 * @classNmae: HttpProtocoUtil
 * @packageName: server
 * @description:
 * @DATE: 2021/7/13 14:28
 */
public class HttpProtocolUtil {

    /**
     * 为响应码200添加请求头信息
     * @return
     */
    public static String getHttpHeader200(long contentLength){
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + contentLength + "\n" +
                "\r\n";
    }

    /**
     * 为响应码200添加请求头信息
     * @return
     */
    public static String getHttpHeader404(){
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + str404.getBytes().length + "\n" +
                "\r\n" + str404;
    }
}
